package lp2;
//bernard lenin costa da silva

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import junit.*;

public class TestePlaylista {
	private Playlista playL1,playL2;
	private Musica musica1,musica2,musica3,musica4;
	
	@Before
	public void criarConstrutor() throws Exception{
		playL1 = new Playlista("lista1");
		playL2 = new Playlista("lista2");
		musica1 = new Musica("dont stay", "live in texas", "Linkin park", "rock", 2005);
		musica2 = new Musica("estravasa", "Claudia verao", "Claudia leite", "axe",2008);
		musica3 = new Musica("paradise", "Paradise best", "Cold play", "pop",2011);
		musica4 = new Musica("blue", "live in texas", "Linkin park", "rock", 2005);
		
	}
	
	@Test
	public void testarConstrutorPlaylista() throws Exception{
		try{
			playL1 = new Playlista("");
		}catch(Exception e){
			Assert.assertEquals("Mensagem errada", "Parametro invalido", e.getMessage());			
		}
		
	}
	
	@Test
	public void testarPesquisarMusicaGenero() throws Exception{
		playL1.addMusica(musica1);
		playL1.addMusica(musica2);
		playL1.addMusica(musica3);
		try{
			playL1.pesquisarMusicaGenero("");
		}catch(Exception e){
			Assert.assertEquals("erro ", "Parametro invalido",e.getMessage());
		}
		Assert.assertTrue(playL1.verificarMusicaGenero("rock"));
		Assert.assertFalse(playL1.verificarMusicaGenero("mpb"));
	}
	
	@Test
	public void testarPesquisarMusicaArtista() throws Exception{
		playL1.addMusica(musica1);
		playL1.addMusica(musica2);
		playL1.addMusica(musica3);
		try{
			playL1.pesquisarMusicaArtista("");
		}catch(Exception e){
			Assert.assertEquals("erro ", "Parametro invalido",e.getMessage());
		}
		
		Assert.assertTrue(playL1.verificarMusicaArtista("Linkin park"));
		Assert.assertFalse(playL1.verificarMusicaArtista("Ivete"));
	}
	
	
	
	@Test 
	public void testarRemoverMusica() throws Exception{
		playL1.addMusica(musica1);
		playL1.addMusica(musica2);
		playL1.addMusica(musica3);
		try{
			playL1.removerMusica("", "Linkin park");
		}catch(Exception e){
			Assert.assertEquals("mensagem errada", "Parametro invalido.",e.getMessage());
		}
		try{
			playL1.removerMusica("dont stay", "");
		}catch(Exception e){
			Assert.assertEquals("mensagem errada", "Parametro invalido.",e.getMessage());
		}
		
		Assert.assertTrue(playL1.verificarRemocaoMusica("dont stay", "Linkin park"));
		Assert.assertFalse(playL1.verificarRemocaoMusica("dont ", "Linkin park"));
	
	}
	
	
	
	

}
